/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.network.topo.pstn;

import java.awt.Color;
import java.awt.Font;

import twaver.AlarmSeverity;
import twaver.Link;
import twaver.ResizableNode;
import twaver.RoundRect;
import twaver.TDataBox;
import twaver.TWaverConst;
import twaver.base.OrthogonalLinkDirectionType;
import twaver.Node;

public class TopologyDataFactory {
    public static void createData(TDataBox box) {
        Node tw130 = new Node();
        tw130.setLocation(356, 139);
        tw130.setImage("/demo/resource/images/tw130.png");
        tw130.setName("TWaver Router");
        tw130.putLabelYOffset(-75);
        tw130.putLabelFont(new Font("Arial", Font.BOLD, 12));
        box.addElement(tw130);

        Node cloudData = new Node();
        cloudData.setLocation(246, 145);
        cloudData.setImage("/demo/resource/images/cloud.png");
        cloudData.setName("DATA");
        cloudData.putLabelYOffset(-30);
        cloudData.putLabelFont(new Font("Arial", Font.BOLD, 12));
        cloudData.putLabelColor(Color.white);
        cloudData.putLabelHighlightable(false);
        cloudData.putRenderColor(Color.GREEN);
        box.addElement(cloudData);

        Link link = new Link(cloudData, tw130);
        link.putLinkWidth(6);
        box.addElement(link);

        Node cloudPSTN = new Node();
        cloudPSTN.setLocation(246, 209);
        cloudPSTN.setImage("/demo/resource/images/cloud.png");
        cloudPSTN.setName("PSTN");
        cloudPSTN.putLabelYOffset(-30);
        cloudPSTN.putLabelFont(new Font("Arial", Font.BOLD, 12));
        cloudPSTN.putLabelColor(Color.white);
        cloudPSTN.putLabelHighlightable(false);        
        cloudPSTN.getAlarmState().setPropagateSeverity(AlarmSeverity.WARNING);
        cloudPSTN.putDrawImageShape(true);       
        box.addElement(cloudPSTN);

        Link orlink = new Link(cloudPSTN, tw130);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        orlink.putLinkWidth(6);
        box.addElement(orlink);

        Node scrambler = new Node();
        scrambler.setLocation(175, 157);
        scrambler.setImage("/demo/resource/images/router.png");
        scrambler.setName("Scrambler");
        box.addElement(scrambler);

        link = new Link(scrambler, cloudData);
        link.putLinkWidth(4);
        link.putLinkFlowing(true);
        link.putLinkFlowingWidth(4);
        link.putLinkFlowingColor(Color.black);
        link.putLinkColor(Color.white);
        link.putLinkOutlineColor(Color.black);
        box.addElement(link);

        for (int i = 0; i < 7; i++) {
            Node node = new Node();
            if (i < 5) {
                node.setLocation(106, 95 + i * 12);
            } else {
                node.setLocation(106, 122 + i * 20);
            }
            node.setImage("/demo/resource/images/router.png");
            box.addElement(node);
            if (i == 4) {
                node.setName("Encoder");
            }

            orlink = new Link(node, scrambler);
            orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
            orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
            orlink.putLinkWidth(1);
            box.addElement(orlink);
        }
        Node node = new Node();
        node.setImage("/demo/resource/images/satellite_antenna.png");
        node.setLocation(31, 90);
        node.setName("Satellite Feed");
        box.addElement(node);

        node = new Node();
        node.setImage("/demo/resource/images/antenna.png");
        node.setLocation(33, 183);
        node.setName("Off Air");
        box.addElement(node);

        node = new Node();
        node.setImage("/demo/resource/images/msc.png");
        node.setLocation(33, 291);
        node.setName("Programming");
        box.addElement(node);

        Node preAmp = new Node();
        preAmp.setImage("/demo/resource/images/cartridge_system.png");
        preAmp.setLocation(191, 292);
        preAmp.setName("Pre-Amp");
        preAmp.addAttachment("attachment1");
        box.addElement(preAmp);

        node = new Node();
        node.setLocation(105, 302);
        node.setImage("/demo/resource/images/router.png");
        node.getAlarmState().setNewAlarmCount(AlarmSeverity.CRITICAL, 5);
        box.addElement(node);
        node.setName("V-OLT");

        link = new Link(node, preAmp);
        link.putLinkWidth(1);
        link.addAttachment("attachment2");
        box.addElement(link);
        link.setSelected(true);

        Node wdm = new Node();
        wdm.setName("WDM");
        wdm.setLocation(432, 146);
        wdm.setImage("/demo/resource/images/wdm.png");
        wdm.putLabelFont(new Font("Arial", Font.BOLD, 12));
        box.addElement(wdm);

        orlink = new Link(preAmp, wdm);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        orlink.putStateOutlineColor(Color.MAGENTA);
        box.addElement(orlink);

        link = new Link(tw130, wdm);
        link.putLinkWidth(1);
        box.addElement(link);

        Node test = new Node();
        test.setLocation(476, 161);
        test.setImage("/demo/resource/images/testing.png");
        test.getAlarmState().addNewAlarm(AlarmSeverity.MAJOR);
        box.addElement(test);

        link = new Link(test, wdm);
        link.putLinkWidth(1);
        box.addElement(link);

        wdm = new Node();
        wdm.setName("WDM");
        wdm.setLocation(516, 146);
        wdm.setImage("/demo/resource/images/wdm.png");
        wdm.putLabelFont(new Font("Arial", Font.BOLD, 12));
        box.addElement(wdm);

        link = new Link(test, wdm);
        link.putLinkWidth(1);
        box.addElement(link);

        Node ont = new Node();
        ont.setName("ONT");
        ont.setLocation(555, 196);
        ont.setImage("/demo/resource/images/mainframe.png");
        box.addElement(ont);

        orlink = new Link(ont, wdm);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        orlink.addAttachment("attachment2");
        box.addElement(orlink);

        node = new ResizableNode();
        node.setImage(TWaverConst.BLANK_IMAGE);
        node.setLocation(470, 65);
        ((ResizableNode)node).setSize(10, 10);
        box.addElement(node);

        orlink = new Link(node, tw130);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(4);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        orlink.addAttachment("attachment1");
        orlink.addAttachment("attachment3");
        box.addElement(orlink);

        Node modem = new Node();
        modem.setImage("/demo/resource/images/modem.png");
        modem.setLocation(560, 98);
        modem.setName("Modem");
        box.addElement(modem);

        RoundRect xDSL = new RoundRect();
        xDSL.setLocation(498, 93);
        xDSL.setName("xDSL");
        box.addElement(xDSL);

        orlink = new Link(xDSL, node);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        orlink = new Link(xDSL, modem);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        RoundRect pots = new RoundRect();
        pots.setLocation(498, 19);
        pots.setName("POTS");
        box.addElement(pots);

        Node phone = new Node();
        phone.setImage("/demo/resource/images/phone.png");
        phone.setLocation(654, 15);
        phone.setName("Phone");
        box.addElement(phone);

        orlink = new Link(phone, pots);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        orlink = new Link(node, pots);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        box.addElement(orlink);

        Node pc = new Node();
        pc.setName("PC");
        pc.setLocation(651, 64);
        box.addElement(pc);

        orlink = new Link(pc, modem);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        Node stb = new Node();
        stb.setImage("/demo/resource/images/router2.png");
        stb.setName("STB");
        stb.setLocation(614, 122);
        box.addElement(stb);
        orlink = new Link(stb, modem);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        Node tv = new Node();
        tv.setImage("/demo/resource/images/terminal.png");
        tv.setName("IPTV/SDV");
        tv.setLocation(646, 152);
        box.addElement(tv);

        Link l = new Link(tv, stb);
        l.setLinkType(TWaverConst.LINK_TYPE_FLEXIONAL);
        l.putLinkWidth(1);
        box.addElement(l);

        phone = new Node();
        phone.setImage("/demo/resource/images/phone.png");
        phone.setLocation(648, 223);
        phone.setName("Phone");
        box.addElement(phone);

        orlink = new Link(phone, ont);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        pc = new Node();
        pc.setName("PC");
        pc.setLocation(648, 266);
        box.addElement(pc);

        orlink = new Link(pc, ont);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        stb = new Node();
        stb.setImage("/demo/resource/images/router2.png");
        stb.setName("STB");
        stb.setLocation(609, 324);
        box.addElement(stb);

        orlink = new Link(stb, ont);
        orlink.setLinkType(TWaverConst.LINK_TYPE_ORTHOGONAL);
        orlink.putLinkWidth(1);
        orlink.putLinkOrthogonalDirection(OrthogonalLinkDirectionType.Y_TO_X);
        box.addElement(orlink);

        tv = new Node();
        tv.setImage("/demo/resource/images/terminal.png");
        tv.setName("IPTV/SDV");
        tv.setLocation(641, 357);
        box.addElement(tv);

        l = new Link(tv, stb);
        l.setLinkType(TWaverConst.LINK_TYPE_FLEXIONAL);
        l.putLinkWidth(1);
        box.addElement(l);
    }
}